home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 7644 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  38 lines

  1. Path: ccnet.com!usenet
  2. From: paulp@ccnet.com (Paul Pedriana)
  3. Newsgroups: comp.lang.c++
  4. Subject: MSVC++ 4.0 compiler really doesn't call subclassed virtual functions in this case.
  5. Date: Sat, 24 Feb 1996 19:36:22 GMT
  6. Organization: Two-Bit Software
  7. Message-ID: <4gnpf9$q8o@ccnet2.ccnet.com>
  8. NNTP-Posting-Host: h96-194.ccnet.com
  9.  
  10. I've got this problem that I know is not my fault. I declare classes
  11.    class A{
  12.       virtual blah();
  13.    };
  14.  
  15.    class B:public A{
  16.       virtual blah();
  17.    };
  18.  
  19.    B myB;
  20.  
  21. And at runtime, calling myB.blah(); causes E:blah() to be called. The reason I
  22. know it is not my fault is because it goes away if I delete the object files for
  23. A and B and recompile. The first time after deleting the object files, the bug
  24. goes away, then the next compile (without re-deleting the obj files) the bug
  25. comes back. Thus I can fix the problem by always deleting the obj files before
  26. compiling. 
  27.  
  28. Has anybody else had this problem with VC++ 4.0? Is it related to incremental
  29. compiling and linking?
  30.  
  31. My guess is that if you compile the above example, code, you won't see this
  32. problem, as in my case the classes aren't quite so simple, and only happen for
  33. some classes, and not for others.
  34.  
  35. Paul Pedriana
  36. paulp@ccnet.com
  37.  
  38.